pub fn goldbach_conjecture() -> u64 {
    let mut odd_composite = vec![];
    let mut n = 9;

    while odd_composite.len() < 2 {
        if !is_prime(n) && !can_be_written_as_goldbach(n) {
            odd_composite.push(n as u64);
        }
        n += 2;
    }
    
    odd_composite.iter().sum()
}

fn is_prime(n: usize) -> bool {
    if n < 2 {
        return false;
    }
    for i in 2..=((n as f64).sqrt() as usize) {
        if n % i == 0 {
            return false;
        }
    }
    true
}

fn can_be_written_as_goldbach(n: usize) -> bool {
    for i in 1.. {
        let square_twice = 2 * i * i;
        if square_twice >= n {
            break;
        }
        if is_prime(n - square_twice) {
            return true;
        }
    }
    false
}
